<?php
namespace api\modules\v1\models\article;

use common\models\Functions;
use common\models\Status;
use yii\base\Exception;

/**
 */
class Article extends \common\models\article\Article
{

    public  function getInfo($id = 0) {
        try {
            $info = static::getOneInfoById($id,['id','title','content','create_time as time']);

            if (empty($info) || $info['status'] == Status::COMMON_RADIO_NO || $info['is_delete'] == Status::COMMON_IS_DELETE) {
                throw new Exception('信息不存在');
            }

            return Functions::formatRestAPI(0, '', $info);
        } catch (Exception $e) {
            return Functions::formatRestAPI(1, $e->getMessage());
        }

    }
}
